package com.yjd.comm.util;

import com.alibaba.fastjson.JSON;
import com.yjd.comm.bank.model.BankModel;
import com.yjd.comm.enums.RepaymentWayEnum;
import com.yjd.comm.enums.TimeUnit;
import com.yjd.comm.fundservice.dto.QKConfig;
import com.yjd.comm.fundservice.dto.QKLoanApplyModel;
import com.yjd.comm.fundservice.dto.QKLoanApplyResponse;
import com.yjd.comm.fundservice.enums.BusTypeEnum;
import com.yjd.comm.fundservice.util.QianKangServerUtil;
import com.yjd.comm.order.model.OrderModel;
import com.yjd.comm.org.model.OrganizationModel;
import com.yjd.comm.user.dto.ContactInfo;
import com.yjd.comm.user.dto.ResidenceInfo;
import com.yjd.comm.user.dto.WorkInfo;
import com.yjd.comm.user.model.UserDataModel;
import com.yjd.comm.user.util.UserUtil;

import java.util.List;

/**
 * Created by yjd-wap on 2018/2/6.
 */
public class QiankangTest {
    private static QKLoanApplyModel buildLoanApplyModel(){
        QKLoanApplyModel request = new QKLoanApplyModel();
        request.setAgent_order_id("10000123");
        request.setLoan_amount(10000);
        request.setLoan_rate(18);
        request.setLoad_period(6);
        request.setRepayment_way(RepaymentWayEnum.TYPE_3.getCode());
        request.setStart_date(""); // optional
        request.setEnd_date(""); // optional
        request.setProduct_name(""); // optional
        request.setProduct_desc(""); // optional
        request.setPayee_bank_account("马俊杰");
        request.setPayee_bank_card("6228480031357575617");
        request.setBorrower_name("陈建栋");
        request.setBorrower_id("350784198310211076");
        request.setBorrower_contact("13850278156");
        request.setBorrower_bank_code(10001); //TODO
        request.setBorrower_bank_card("6227001842510451955");


        request.setBorrower_work_name("上海天正信息有限公司");
        request.setBorrower_work_address("上海天山路1200号");


        request.setBorrower_address("上海北京东路200号");
        request.setBorrower_home_address("上海北京东路200号");
        request.setBorrower_census_address("上海北京东路210号");


        request.setBorrower_contact_first_name("李明");
        request.setBorrower_contact_first_phone("15800658324");
        request.setBorrower_contact_first_relation("兄弟");
        request.setBorrower_contact_second_name("李强");
        request.setBorrower_contact_second_phone("15800658328");
        request.setBorrower_contact_second_relation("兄弟");

        request.setCallback_url("http://sh.yimeifenqi.org/loan/callback");

        return request;
    }

    public static void main(String[] args) {
        QKConfig config = new QKConfig();
        config.setAgent_id("317316");
        config.setAgent_secret("vf7HHNCwFCqkuzEKZioQh8e6YVrziuuX");
        config.setServer_url("https://hd.kuaixin360.com");
        config.setQk_public_key("MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQCDkBeU9Icd+owsn6ROd6aC8InWQFpG8seuY5e7NEaKASxsXOXkCusRkYo0PktTYMIkyUDyqDpv69bmVBrRt2flifIrAQuXmi4eE8XNa/T4bccLFL0NiQJ9ghdu77ptpqFbzqvA2nIcbyd8r/wmbxt2fPXghSXSehbK/Bc5Zi+HvQIDAQAB");
        config.setMy_private_key("MIICdwIBADANBgkqhkiG9w0BAQEFAASCAmEwggJdAgEAAoGBALI2/cxYM1y1MIgu2ARP/52YorgTXvkTx5Hg3/zhsFiKdmiZAuseWmMfuZ1ykEl7ioicpL1EWI0kqfZsUBkftXTK8YADu71uaA+xvRBDKgVX98ea/FwJnWGlHYpJ8lPaf3sIUQZ2IRYpvOpcWdbfu+RDG24GKVWDeBrqA+pLUfQ3AgMBAAECgYBG7XH3OQdAF3C4UoRwuvIN4+inADalRQUBfxFGUQBhTMIxgOxTbSImH0M9cZIRXNTW6Bj8ps3jZrsqMxNx3FfX9vh8xujUZAGMYuKuh5RzWWsf7gxJWVM+Vs3y5vBX+I2/TbdzbkPwIL6xwEnkLnWyciqKBSvompnWfTwhsSD+CQJBAPb6PJXEMQ7M8fi7hB6yop74xaabxg3NeRAPA5IfG5O+N1p7n34fl4LHN2VJpdhtcyYi+f6GoUH4No35abD4shMCQQC4ua2IoL47/5OnQBfdGlyH4MtQVIoIcqQ9vcNQ3XytSIidIZVbPWkNiUUWnJF8M78X4HREqjHt/aD65cuvCpnNAkEAvpyaravhgN7D0YhHi7mqsK6nPNL0pCp0yOQNiXTgv8IKzpainaCcOp6uLkoM6WBvgnt0HfCh/FwpHqHj5GXMaQJBAK+ETSxqfxaHCoZ50bLV32GD5+qVyOmp9ABuE+z75gDH0HZseHtO6EhiS3Dmpx16FXHcZNzxUautt41tVpEk42kCQGCDFDuQL6R+f4gb/ugWdLi0HsGu9IfgAW6Cd6iTIISYRbFUuUgdq+KzGuGd7iq8l2Xyoofy3v8mqsHh+eWO4cs=");
        QKLoanApplyModel applyModel = buildLoanApplyModel();
        try {
            QKLoanApplyResponse askResponse = QianKangServerUtil.sendMsgTest(config,applyModel,"/product/byy/anon/loan-request",
                    BusTypeEnum.LOAN_APPLY,applyModel.getAgent_order_id(), QKLoanApplyResponse.class);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}
